package com.lancer.springbootdemo.tacos.web;

import com.lancer.springbootdemo.tacos.beans.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @className: OrderController
 * @description: TODO 类描述
 * @author: Lancer Dai
 * @date: 2021/9/27
 **/
@Slf4j
@Controller
@RequestMapping("/orders")
public class OrderController {
    @GetMapping("/current")
    public String orderForm(Model model){
        model.addAttribute("order",new Order());
        return "orderForm";
    }

    @PostMapping
    public String processOrder(Order order){
        log.info("Order submitted : " + order);
        return "redirect:/";
    }
}
